package practice;

import java.util.ArrayList;
import java.util.Scanner;

public class 菜单 {
    public static void main(String[] args) {
        FoodOperator mune = new FoodOperator();
        mune.start();
    }
}


class FoodOperator {
    private ArrayList<food> mune = new ArrayList<>();

    public void addFood(String title, double price, String name) {
        mune.add(new food(name, price, title));
    }

    public void addFood() {
        food f = new food();
        Scanner sc = new Scanner(System.in);
        System.out.print("请输入菜品名字：");
        f.setName(sc.next());
        System.out.print("请输入价格：");
        f.setPrice(sc.nextDouble());
        System.out.println("请输入描述：");
        f.setTitle(sc.next());
        mune.add(f);
        System.out.println("添加完成");
    }

    public void showFoodList() {
        if (mune.size() == 0) {
            System.out.println("该菜单里面还没有菜品");
        } else {
            for (int i = 0; i < mune.size(); i++) {
                System.out.println(mune.get(i).getName() + " " + mune.get(i).getPrice() + " " + mune.get(i).getTitle());
            }
        }
    }

    public void start() {
        while (true) {
            Scanner sc = new Scanner(System.in);
            System.out.println("请选择功能");
            System.out.println("1、添加菜品");
            System.out.println("2、展示菜单");
            System.out.println("3、结束");
            String myc = sc.next();
            switch (myc) {
                case "1":
                    addFood();
                    break;
                case "2":
                    showFoodList();
                    break;
                case "3":
                    System.out.println("成功推出");
                    return;
                default:
                    System.out.println("你输入的命令不存在");
            }
        }
    }
}

class food {
    String name;
    double price;
    String title;

    public food() {
    }

    public food(String name, double price, String title) {
        this.name = name;
        this.price = price;
        this.title = title;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public double getPrice() {
        return price;
    }

    public void setPrice(double price) {
        this.price = price;
    }

    public String getTitle() {
        return title;
    }

    public void setTitle(String title) {
        this.title = title;
    }
}
